package com.shopnight.config;


import org.springframework.amqp.core.*;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 订单队列
 *
 *
 * 2个队列
 * 1个交换机
 * 2个绑定
 */

@Configuration
public class MyMQConfig {

    //订单释放队列
    @Bean
    public Queue orderReleaseOrderQueue(){
//        Queue queue = new Queue("order.release.order.queue", true,false, false);
        return new Queue("orderQueue", true,false, false);
    }

    //订单事件交换机
    @Bean
    public Exchange orderEventExchange(){
        //全惨构造直接交换机: 交换机名,是否持久化,是否自动删除，添加额外参数
//        return new TopicExchange("order-event-exchange",true,false);
//        return new DirectExchange("order-event-exchange",true,false);
        return new TopicExchange("order",true,false);


    }


    //订单释放绑定
    @Bean
    public Binding orderReleaseOrderBingding(){
        return new Binding("orderQueue",//绑定队列
                Binding.DestinationType.QUEUE,//绑定类型  目的地类型 是个队列
                "order",//绑定交换机
                "create",//路由键
                null);//自定义属性
    }



}
